#include "porting.h"
#include <gtest4c.h>
#include <lnthread.h>

#include "fileio.h"

C_TEST (base, fileio)
{
  const char* lines[] =
  {
    "test line",
    "",
    "test_line2",
    NULL
  };

  const char* lines_empty [] =
  {
    NULL
  };

  int n;
  char** rlines;
  struct respool_t respool;
  char buffer[2048];

  n  = write_lines ("fileio_test.txt", (char**)lines);

  C_ASSERT_TRUE ( n == 0 );

  respool_init (respool,buffer, NULL);

  rlines = read_lines ("fileio_test.txt", &respool);

  C_ASSERT_TRUE ( string_list_count (rlines) == 3 );

  rlines = read_lines ("fileio_test.no.txt", &respool);
  C_ASSERT_TRUE ( string_list_count (rlines) == 0 );

  respool_close (&respool);
};

C_TEST (base, alloc)
{
  LN_THREAD_PTR thrd = thrd_current();
};

C_TEST (base, thread)
{
  LN_THREAD_PTR thrd = thrd_current();
}

C_TEST_CASE_BEGIN (base_testCases)
  C_TEST_CASE (base, fileio )
  C_TEST_CASE (base, alloc )
  C_TEST_CASE (base, thread )
C_TEST_CASE_END ()

